﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics.Contracts;
using System.Globalization;
using System.IO;

namespace YasharEl.Infrastructure.ResourcesManagement
{
    [ContractClass(typeof(ResourceManagerContract))]
    public interface IResourceManager
    {
        #region GetString Methods

        string GetString(string name);
        string GetString(string name, CultureInfo culture);

        #endregion

        #region GetObject Methods

        object GetObject(string name);
        object GetObject(string name, CultureInfo culture);

        #endregion

        #region GetStream Methods

        UnmanagedMemoryStream GetStream(string name);
        UnmanagedMemoryStream GetStream(string name, CultureInfo culture);

        #endregion

        #region ApplyResources Methods

        void ApplyResources(object value, string objectName);
        void ApplyResources(object value, string objectName, CultureInfo culture);

        #endregion
    }

    [ContractClassFor(typeof(IResourceManager))]
    internal abstract class ResourceManagerContract : IResourceManager
    {
        public string GetString(string name)
        {
            Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(name), "name could not be null or empty.");
            return default(string);
        }

        public string GetString(string name, CultureInfo culture)
        {
            Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(name), "name could not be null or empty.");
            return default(string);
        }

        public object GetObject(string name)
        {
            Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(name), "name could not be null or empty.");
            return default(object);
        }

        public object GetObject(string name, CultureInfo culture)
        {
            Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(name), "name could not be null or empty.");
            return default(object);
        }

        public UnmanagedMemoryStream GetStream(string name)
        {
            Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(name), "name could not be null or empty.");
            return default(UnmanagedMemoryStream);
        }

        public UnmanagedMemoryStream GetStream(string name, CultureInfo culture)
        {
            Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(name), "name could not be null or empty.");
            return default(UnmanagedMemoryStream);
        }

        public void ApplyResources(object value, string objectName)
        {
            Contract.Requires<ArgumentNullException>(value != null, "value could not be null.");
            Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(objectName), "objectName could not be null or empty.");
        }

        public void ApplyResources(object value, string objectName, CultureInfo culture)
        {
            Contract.Requires<ArgumentNullException>(value != null, "value could not be null.");
            Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(objectName), "objectName could not be null or empty.");
        }
    }
}
